#include <iostream>

using namespace std;

class Point1
{
public:
    //compilor set a default constructor
    void print()
    {
        cout << "(" << _x << "," << _y << ")" << endl;
    }

private:
    int _x;
    int _y;
};

class Point2
{
public:
    //define a constructor
    Point2();
    Point2(int x, int y);
    void print();

private:
    //class has memory alignment
    //alignment with the max size of data member
    int _y; // int _y = 0; //set default value
    char _c;
    int _x;
    //int _y use 4 bytes
    //char _c use 1 byte
    //int _x use 4 bytes
    //but has memory alignment, _c use 4 byte actually
    //memory model likes: (O is use, X is unuse)
    //OOOO
    //OXXX
    //OOOO
};

//best to define data member in init list of constructor
Point2::Point2(): _x(0), _c('a'), _y(0){}
Point2::Point2(int x, int y): _y(x), _c('a'), _x(y){}

void Point2::print()
{
    cout << "(" << _x << "," << _y << ")" << endl;
}


void test()
{
    Point1 p1;
    p1.print();

    Point2 p2;
    p2.print();

    Point2 p3(3,4);
    p3.print();

    cout << "sizeof Point2 = " << sizeof(Point2) << endl;
}

int main()
{
    test();
    return 0;
}

